package com.glory.dgcpcpda.entity;

import android.os.Build;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

/**
 * FileName: BinInfoEntity
 * Author: XJH
 * Date: 2020/5/29 15:21
 * Description:
 * History:
 */
public class BinInfoEntity implements Serializable {
    private List<BinInfo> HBINLIST;
    private String ISTESTTYPE;
    private String TESTTYPE;
    private String STATIONAB;
    private String LOTID;
    private String LOTCOUNT;
    private String TESTERIDS ;
    private String PRODUCTMODEL ;
    private String EQPTYPE;
    private String GRADINGMARKER;

    public String getGRADINGMARKER() {
        return GRADINGMARKER == null ? "" : GRADINGMARKER;
    }

    public void setGRADINGMARKER(String GRADINGMARKER) {
        this.GRADINGMARKER = GRADINGMARKER;
    }

    public String getSTATIONAB() {
        return STATIONAB == null ? "" : STATIONAB;
    }

    public void setSTATIONAB(String STATIONAB) {
        this.STATIONAB = STATIONAB;
    }

    public String getLOTID() {
        return LOTID == null ? "" : LOTID;
    }

    public void setLOTID(String LOTID) {
        this.LOTID = LOTID;
    }

    public String getLOTCOUNT() {
        return LOTCOUNT == null ? "" : LOTCOUNT;
    }

    public void setLOTCOUNT(String LOTCOUNT) {
        this.LOTCOUNT = LOTCOUNT;
    }

    public String getTESTERIDS() {
        return TESTERIDS == null ? "" : TESTERIDS;
    }

    public void setTESTERIDS(String TESTERIDS) {
        this.TESTERIDS = TESTERIDS;
    }

    public String getPRODUCTMODEL() {
        return PRODUCTMODEL == null ? "" : PRODUCTMODEL;
    }

    public void setPRODUCTMODEL(String PRODUCTMODEL) {
        this.PRODUCTMODEL = PRODUCTMODEL;
    }

    public String getEQPTYPE() {
        return EQPTYPE == null ? "" : EQPTYPE;
    }

    public void setEQPTYPE(String EQPTYPE) {
        this.EQPTYPE = EQPTYPE;
    }

    public String getTESTTYPE() {
        if (TESTTYPE == null || TESTTYPE.equals("")){
            return "";
        }
        StringBuffer buffer = new StringBuffer();
        buffer.append(TESTTYPE);
        switch (TESTTYPE){
            case "FT":
                buffer.append("/初测");
                break;
            case "RT":
                buffer.append("/复测");
                break;
            case "MT":
                buffer.append("/外观");
                break;
            case "CT":
                buffer.append("/拆编");
                break;
            case "YZ":
                buffer.append("/跑校");
                break;
            case "QA":
                buffer.append("/抽样");
                break;
        }
        return buffer.toString();
    }

    public void setTESTTYPE(String TESTTYPE) {
        this.TESTTYPE = TESTTYPE;
    }

    public List<BinInfo> getHBINLIST() {
        if (HBINLIST == null) {
            return new ArrayList<>();
        }

        Collections.sort(HBINLIST, (binInfo, t1) -> binInfo.getBINNO().compareTo(t1.getBINNO()));
        return HBINLIST;
    }

    public String getISTESTTYPE() {
        return ISTESTTYPE == null ? "" : ISTESTTYPE;
    }

    public void setISTESTTYPE(String ISTESTTYPE) {
        this.ISTESTTYPE = ISTESTTYPE;
    }

    public void setHBINLIST(List<BinInfo> HBINLIST) {
        this.HBINLIST = HBINLIST;
    }


    public static class BinInfo implements Serializable{
        private String BINNO;
        private String BINNAME;
        private int BINQTY;
        private String BINACTUAL;
        private String BINTYPE;
        private boolean isChecked = false;

        public String getBINTYPE() {
            return BINTYPE == null ? "" : BINTYPE;
        }

        public void setBINTYPE(String BINTYPE) {
            this.BINTYPE = BINTYPE;
        }

        public String getBINACTUAL() {
            return BINACTUAL == null ? "" : BINACTUAL;
        }

        public void setBINACTUAL(String BINACTUAL) {
            this.BINACTUAL = BINACTUAL;
        }

        public BinInfo() {
        }

        public BinInfo(String BINNO, String BINNAME) {
            this.BINNO = BINNO;
            this.BINNAME = BINNAME;
        }

        public String getBINNO() {
            return BINNO == null ? "" : BINNO;
        }

        public void setBINNO(String BINNO) {
            this.BINNO = BINNO;
        }

        public String getBINNAME() {
            return BINNAME == null ? "" : BINNAME;
        }

        public void setBINNAME(String BINNAME) {
            this.BINNAME = BINNAME;
        }

        public int getBINQTY() {
            return BINQTY;
        }

        public int getNo(){
            String no = BINNO.replace("BIN", "");
            return Integer.parseInt(no);
        }

        public void setBINQTY(int BINQTY) {
            this.BINQTY = BINQTY;
        }

        public boolean isChecked() {
            return isChecked;
        }

        public void setChecked(boolean checked) {
            isChecked = checked;
        }
    }
}
